/*
 * 
 * Libman
 * 
 * Daniel Kaufmann, Martin Lang, Simon Moosbrugger,
 * Stefan Mayer, Stephan Halbeisen
 * 
 */
package application.controller.server;

import java.util.List;

import application.exceptions.InsufficientClientRightsException;
import application.exceptions.SessionException;

/**
 * The Class AbstractUseCaseController.
 */
public abstract class AbstractUseCaseController {
	private static SessionController _sc;
	protected static List<String> _allowedRoles;
	
	protected AbstractUseCaseController(){
		if(_sc == null){
			_sc = new SessionController();			
		}
	}
	
	protected void checkLogin(String sessionId, String clientIp) throws SessionException, InsufficientClientRightsException{
		String roleName = _sc.checkSession(sessionId, clientIp);
		
		if(!_allowedRoles.contains(roleName)){
			throw new InsufficientClientRightsException();
		}
	}
}
